home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Tools & Utilities
/
Collection of Tools and Utilities.iso
/
asmutil
/
asm_n_z.zip
/
TSRSH.ASM
< prev
next >
Wrap
Assembly Source File
|
1987-02-02
|
27KB
|
1,100 lines
PAGE 60,132
TITLE Ram-Resident Program Shell, Preliminary Version (Lesson 2)
SUBTTL Date 02-02-87 -- Tutorial for Microsoft Forum Version 0.03
;-----------------------------------------------------------------------------
; Ram-Resident Program Shell
;
;
;The software, documentation and source code are:
;
; (C) Copyright 1986, 1987
; Chip Rabinowitz
; All Rights Reserved
;
; 51 East Rogues Path
; Huntington Station NY 11746
; Assistant SysOp, Microsoft Forum, Compuserve PPN 76703,350
;
;
;COPYRIGHT NOTICE AND WARRANTY INFORMATION
;-----------------------------------------
;
;This document ("the source code"), other accompanying written and disk-based
;notes and specifications ("the documentation"), and all referenced and related
;program files accompanying the source code and the documentation ("the
;software") are copyrighted by Chip Rabinowitz.
;
;This program has been uploaded to Compuserve as part of a Tutorial in how
;to write Terminate-But-Stay-Resident programs, being conducted on
;Compuserve's Microsoft Special Interest Group during early 1987/
;
;This code (and all other code uploaded by the Copyright Holder as a
;part of this TSR Tutorial) may be used with the following restrictions:
;
;(1) If all or part of this code is used as part of a software package of
;ANY kind, the following acknowledgement must be used in the Documentation
;accompanying said package:
;
; 'Parts of the Resident Program Management for this Product are'
; 'Copyright (C) 1986, 1987 by Chip Rabinowitz, and are incorporated'
; 'into this product courtesy of the Ringmaster Development Team'
;
;(2) If all or part of this code is used as part of a software package that
;is placed in the public domain, no further restrictions apply.
;
;(3) If all or part of this code is used as part of a software package that
;is being distributed as 'shareware', a one-time-only donation of $10 will be
;accepted for the express purpose of continuing research into TSR standards.
;Note that this is a voluntary contribution, and should be sent to the
;Ringmaster Development Team at the address printed above.
;
;(4) If all or part of this code is used as part of a software package that
;will be distributed as a commercial product, a one-time-only payment of
;$25 will be accepted the express purpose of continuing research into TSR
;standards. Note that in THIS CASE ONLY, this is not a voluntary
;contribution. Commercial Developers are REQUIRED to make payment prior to
;incorporating these routines into their product.
;
;No copy of the source code may be distributed or given away without the
;accompanying documentation; and this notice must not be removed.
;
;There is no warranty of any kind associated with this software, and the
;copyright owner is not liable for damages of any kind. By using this
;software, you agree to this.
;
;
XON equ 11h
XOFF equ 13h
TRUE equ 1
FALSE equ 0
CR equ 0dh
LF equ 0ah
TAB equ 9
HOTKEYON equ 01h ;hot key pressed
SHIFTSON equ 02h ;shift states match
TSRACTIVE equ 04h ;tsr is running in foreground
INT28ACTIVE equ 08h ;INT28 routine is running in background
KB_DATA equ 60h
KB_CTL equ 61h
KB_FLG1 equ 17h
KB_FLG2 equ 18h
BIOS_DATA equ 40h
code segment para public 'CODE'
org 100h
assume cs:code, ds:code, es:code
start: jmp begin
db 1bh,'[2J'
cpyrt db 'Ram-Resident Program Shell, Preliminary Version (Lesson 2)',
db CR,LF,LF
db 'Copyright (C) 1986, 1987 Chip Rabinowitz',
db CR,LF,'All Rights Reserved',CR,LF,LF,'$'
hello db 'Hello World!',CR,LF,'$'
bad_dos_msg db 'Incompatible DOS version .... Aborting!',07h,CR,LF,'$'
tsr_parms:
PSP dw ? ;PSP of TSR
OLDPSP dw ? ;location to save current PSP
DTA dd ? ;DTA of TSR
OLDDTA dd ? ;location to save current DTA
DSEG dw ? ;TSR's Data Segment
SSEG dw ? ;TSR's Stack Segment ....
SPTR dw 0fffeh ;.... and Stack Pointer
ISSEG dw 0 ;interrupted SS ...
ISPTR dw 0 ;..... and SP
SHIFTST db 0 ;Shift State to Activate
HOTKEY db 0ffh ;scan code to activate
STATUS dw 0 ;current status words
POPUP dd 0 ;far pointer to popup routine
intflags db 0
ININT13 equ 04h ;Bios disk interrupt
ININT21 equ 08h ;DOS interrupt
dosversion db 0 ;current version of DOS
waitcount db 0 ;wait to activate count
indosflag dd 0 ;Pointer to INDOS flag
doscriterr dd 0 ;Pointer to DOS Critical Error Flag
dossseg dw 0 ;pointer to dos stack segment
dossptr dw 0 ;pointer to dos stack pointer
dossize dw 0 ;dos stack size
dos21funcs label byte
db 0, 0, 0, 0, 0, 0, 0, 0 ;0-7
db 0, 0, 0, 0, 0, 0ffh, 0ffh, 0ffh ;8-f
db 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh ;10-17
db 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh ;18-1f
db 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0, 0ffh ;20-27
db 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0 ;28-2f
db 0ffh, 0, 0, 0, 0, 0, 0ffh, 0ffh ;30-37
db 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh ;38-3f
db 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh ;40-47
db 0, 0, 0, 0, 0ffh, 0, 0ffh, 0ffh ;48-4f **
db 0, 0, 0, 0, 0ffh, 0, 0ffh, 0ffh ;50-57
db 0, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0, 0 ;58-5f
db 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh ;60-67
;
; ***************************************************************************
; These are the bios interrupt vectors
;
BIOSI8 equ 08h ;Bios Timer interrupt
BIOSI9 equ 09h ;BIOS Hardware Keyboard interrupt
BIOSIB equ 0Bh
BIOSIC equ 0Ch
BIOSI10 equ 10h
BIOSI13 equ 13h ;Bios Disk interrupt
BIOSI14 equ 14h
BIOSI15 equ 15h
BIOSI16 equ 16h ;Bios Keyboard interrupt
BIOSI17 equ 17h
BIOSI1C equ 1Ch
DOSI21 equ 21h ;DOS service router interrupt
DOSI28 equ 28h ;DOS Idle interrupt
DOSI33 equ 33h ;mouse interrupt
BIOSI1B equ 1Bh
DOSI23 equ 23h
DOSI24 equ 24h
;
oldint8 dd 0 ;BIOS Hardware Timer Interrupt
db BIOSI8
dw offset newint8 ;replacement vector
oldint9 dd 0 ;BIOS Hardware Keyboard Interrupt
db BIOSI9
dw offset newint9 ;replacement vector
oldint13 dd 0 ;BIOS Disk Interrupt
db BIOSI13
dw offset newint13 ;replacement vector
oldint16 dd 0 ;BIOS Software Keyboard Interrupt
db BIOSI16
dw offset newint16 ;replacement vector
oldint21 dd 0 ;DOS Services Interrupt
db DOSI21
dw offset newint21 ;replacement vector
oldint28 dd 0 ;DOS Idle Interrupt
db DOSI28
dw offset newint28 ;replacement vector
oldint1B dd 0 ;control-C vector
db BIOSI1B
dw offset intret ;replacement vector
oldint23 dd 0 ;control-C vector
db DOSI23
dw offset intret ;replacement vector
oldint24 dd 0 ;critical error vector
db DOSI24
dw offset newint24 ;replacement vector
;
; ***************************************************************************
; Function to restore interrupts.
;
; If AX=0, this function does popup-interrupts (1B, 23 and 24)
; If AX=anything else, this function does initial interrupts
;
restore_int proc near
push ds
push ax
push dx
push si
push di
push cx
mov di,7 ;7 bytes per structure
or ax,ax
jnz restore1
mov cx,3 ;three times through
mov si,offset oldint1B ;start at table beginning
jmp restore_loop
restore1:
mov cx,06h ;six interrupts!
mov si,offset oldint8 ;top of table
restore_loop:
push cx
push di ;save structure size
push ds
mov al,4[si] ;interrupt number
mov dx,[si] ;IP of interrupt vector
mov ds,2[si] ;CS of interrupt vector
mov ah,25h ;set interrupt vector function
int 21h
pop ds
xor ax,ax ;clear this entry from table
mov [si],ax ;so it shows not used
mov 2[si],ax
pop di ;get size back
add si,di ;do it again
pop cx
loop restore_loop
pop cx
pop di
pop si
pop dx
pop ax
pop ds
ret
restore_int endp
;
; ***************************************************************************
; Function to set interrupts.
;
; If AX=0, this function does popup-interrupts (1B, 23 and 24)
; If AX=anything else, this function does initial interrupts
;
setup_int proc near
push es
push ax
push bx
push dx
push di
push si
push cx
mov di,7 ;7 bytes per structure
or ax,ax
jnz setup1